home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* View_Directory --- List files in current directory *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE View_Directory;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: View_Directory *)
- (* *)
- (* Purpose: Lists files in current MSDOS directory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* View_Directory; *)
- (* *)
- (* Calls: View_Prompt *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* Dir_Get_Default_Drive *)
- (* Dir_Get_Current_Path *)
- (* Dir_Find_First_File *)
- (* Dir_Find_Next_File *)
- (* Dir_Convert_Time *)
- (* Dir_Convert_Date *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Iok : INTEGER;
- Drive_Ch : CHAR;
- Cur_Drive_Ch : CHAR;
- File_Entry : Directory_Record;
- S_File_Name : STRING[14];
- S_File_Time : STRING[8];
- S_File_Date : STRING[8];
- S_File_Size : REAL;
- S_File_Xmodem_Time : STRING[8];
- S_File_Attributes : STRING[6];
- Fs1 : REAL;
- Fs2 : REAL;
- I : INTEGER;
- J : INTEGER;
- L : INTEGER;
- Dir_Spec : AnyStr;
- View_Ch : CHAR;
- Total_File_Size : REAL;
- Total_File_Count : INTEGER;
- Free_Space : REAL;
- Path_Name : AnyStr;
- File_Ref_Name : STRING[12];
-
- LABEL
- View_Exit;
-
- BEGIN (* View_Directory *)
- (* Draw view menu *)
-
- Save_Partial_Screen( Saved_Screen, 5, 4, 75, 24 );
- Draw_Menu_Frame( 5, 4, 75, 24, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'View Directory' );
-
- Dir_Spec := '';
- TextColor( Menu_Text_Color_2 );
- WRITELN('Enter search specification (*.* for all): ');
- WRITE ('>');
- TextColor( Menu_Text_Color );
- Read_Edited_String( Dir_Spec );
-
- FOR I := 1 TO 3 DO
- BEGIN
- GoToXY( 1 , I );
- ClrEol;
- END;
-
- IF ( Dir_Spec = CHR( ESC ) ) THEN
- GOTO View_Exit;
- (* Get current drive and path if none given *)
-
- Drive_Ch := Dir_Get_Default_Drive;
- Cur_Drive_Ch := Drive_Ch;
- Iok := Dir_Get_Current_Path( Drive_Ch , Path_Name );
- File_Ref_Name := '*.*';
-
- IF ( Dir_Spec <> '' ) THEN
- BEGIN
- (* Get drive *)
-
- I := POS( ':' , Dir_Spec );
- IF ( I <> 0 ) THEN
- BEGIN
- Drive_Ch := Dir_Spec[1];
- Dir_Spec := Substr( Dir_Spec, I + 1, LENGTH( Dir_Spec ) - I );
- IF( Drive_Ch <> Cur_Drive_Ch ) THEN
- Path_Name := '';
- END
- ELSE
- Drive_Ch := Dir_Get_Default_Drive;
-
- (* Get path and file name *)
-
- IF ( POS( '\' , Dir_Spec ) = 0 ) THEN
- File_Ref_Name := Dir_Spec
- ELSE
- BEGIN
-
- L := LENGTH( Dir_Spec );
- J := L + 1;
-
- REPEAT
- J := J - 1;
- UNTIL ( J <= 1 ) OR ( Dir_Spec[J] = '\' );
-
- Path_Name := Substr( Dir_Spec, 1, J );
- File_Ref_Name := Substr( Dir_Spec, J + 1, L - J );
-
- END;
-
- END;
- (* Build wildcard for directory search *)
- Dir_Spec := Drive_Ch + ':';
-
- IF ( Path_Name <> '' ) THEN
- Dir_Spec := Dir_Spec + '\' + Path_Name + '\';
-
- IF ( File_Ref_Name <> '' ) THEN
- Dir_Spec := Dir_Spec + File_Ref_Name
- ELSE
- Dir_Spec := Dir_Spec + '*.*';
-
- I := POS( '\\', Dir_Spec );
-
- WHILE ( I > 0 ) DO
- BEGIN
- DELETE( Dir_Spec, I, 1 );
- I := POS( '\\', Dir_Spec );
- END;
- (* Display directory title *)
-
- RvsVideoOn( Menu_Text_Color , BLACK );
-
- GoToXY( 1 , 1 );
-
- WRITE('LISTING OF DIRECTORY: ',Dir_Spec);
- ClrEol;
- WRITELN;
- WRITE(' File Name Size Date Time Attributes Xfer Time');
- ClrEol;
- WRITELN;
-
- RvsVideoOff( Menu_Text_Color , BLACK );
-
- (* Reset window so header doesn't vanish *)
- Window( 6, 7, 74, 23 );
- GoToXY( 1 , WhereY );
- (* List the directory contents *)
-
- View_Count := 0;
- View_Done := ( Dir_Find_First_File( Dir_Spec, File_Entry ) <> 0 );
-
- Total_File_Size := 0.0;
- Total_File_Count := 0;
-
- WHILE( NOT View_Done ) DO
- BEGIN
- (* Display Next Directory Entry *)
- S_File_Name := '';
- I := 1;
- (* Pick up file name *)
-
- WHILE( ( I <= 14 ) AND ( File_Entry.File_Name[I] <> CHR(0) ) ) DO
- BEGIN
- S_File_Name := S_File_Name + File_Entry.File_Name[I];
- I := I + 1;
- END;
- (* Pick up creation date and time *)
-
- Dir_Convert_Time( File_Entry.File_Time , S_File_Time );
- Dir_Convert_Date( File_Entry.File_Date , S_File_Date );
-
- (* Pick up file size *)
-
- Fs1 := File_Entry.File_Size[1];
- Fs2 := File_Entry.File_Size[2];
-
- IF Fs1 < 0 THEN Fs1 := Fs1 + 65536.0;
- IF Fs2 < 0 THEN Fs2 := Fs2 + 65536.0;
-
- S_File_Size := Fs2 * 65536.0 + Fs1;
- Total_File_Size := Total_File_Size + S_File_Size;
-
- (* Pick up transfer time *)
-
- S_File_Xmodem_Time := TimeString( ROUND( ( S_File_Size / 128.0 ) + 0.49 ) *
- ( Trans_Time_Val / Baud_Rate ) ,
- Military_Time );
-
- (* Determine attributes *)
- S_File_Attributes := '';
-
- WITH File_Entry DO
- BEGIN
- IF ( File_Attr AND Dir_Attr_Read_Only ) <> 0 THEN
- S_File_Attributes := 'R';
- IF ( File_Attr AND Dir_Attr_Hidden ) <> 0 THEN
- S_File_Attributes := S_File_Attributes + 'H';
- IF ( File_Attr AND Dir_Attr_System ) <> 0 THEN
- S_File_Attributes := S_File_Attributes + 'S';
- IF ( File_Attr AND Dir_Attr_Volume_Label ) <> 0 THEN
- S_File_Attributes := S_File_Attributes + 'V';
- IF ( File_Attr AND Dir_Attr_Subdirectory ) <> 0 THEN
- S_File_Attributes := S_File_Attributes + 'D';
- IF ( File_Attr AND Dir_Attr_Archive ) <> 0 THEN
- S_File_Attributes := S_File_Attributes + 'A';
- END;
-
- IF ( S_File_Attributes = '' ) THEN
- S_File_Attributes := 'N';
-
- (* Display entry *)
-
- WRITELN( S_File_Name:14, ' ', S_File_Size:8:0, ' ', S_File_Date, ' ',
- S_File_Time,' ',S_File_Attributes:10,' ',
- S_File_Xmodem_Time );
-
- (* Increment count of lines displayed *)
-
- View_Count := View_Count + 1;
-
- (* Prompt if end of screen *)
- IF View_Count > 15 THEN
- View_Prompt( View_Done , View_Count );
-
- (* Increment file count *)
-
- Total_File_Count := Total_File_Count + 1;
-
- View_Done := View_Done OR ( Dir_Find_Next_File( File_Entry ) <> 0 );
-
- END;
- (* Display total file size and free space *)
- WRITELN;
-
- View_Count := View_Count + 1;
- IF View_Count > 15 THEN
- View_Prompt( View_Done , View_Count );
-
- Free_Space := Dir_Get_Free_Space( Drive_Ch );
-
- WRITELN( Total_File_Size:8:0, ' bytes in ', Total_File_Count, ' files; ',
- Free_Space:8:0,' bytes free.');
-
- View_Count := View_Count + 1;
- IF View_Count > 15 THEN
- View_Prompt( View_Done , View_Count );
-
- (* Issue final end-of-directory prompt *)
-
- RvsVideoOn( Menu_Text_Color , BLACK );
-
- WRITE('Viewing of directory complete. ',
- 'Hit ESC to continue.');
- ClrEol;
-
- RvsVideoOff( Menu_Text_Color , BLACK );
-
- (* Swallow terminating character *)
- Read_Kbd( View_Ch );
- IF ( View_Ch = CHR( ESC ) ) AND KeyPressed THEN
- READ( Kbd, View_Ch );
- (* Restore previous screen *)
- View_Exit:
-
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* View_Directory *);
-
- (*----------------------------------------------------------------------*)
- (* Log_Drive_Change --- Change current logged drive *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Log_Drive_Change;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Log_Drive_Change *)
- (* *)
- (* Purpose: Change current logged drive *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Log_Drive_Change *)
- (* *)
- (* Calls: Dir_Get_Default_Drive *)
- (* Dir_Set_Default_Drive *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Drive_Ch : CHAR;
- Drive_No : INTEGER;
- Drive_Count : INTEGER;
-
- BEGIN (* Log_Drive_Change *);
- (* Draw logged drive change menu *)
-
- Save_Partial_Screen( Saved_Screen, 5, 10, 55, 15 );
-
- Draw_Menu_Frame( 5, 10, 55, 15, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Change Current Logged Drive' );
-
- GoToXY( 1 , 1 );
- Drive_Ch := Dir_Get_Default_Drive;
-
- TextColor( Menu_Text_Color_2 );
- WRITE('Current logged drive is: ');
- TextColor( Menu_Text_Color );
- WRITE( Drive_Ch );
-
- GoToXY( 1 , 2 );
-
- TextColor( Menu_Text_Color_2 );
- WRITE('Enter letter for new logged drive: ');
-
- READ( Kbd , Drive_Ch );
-
- TextColor( Menu_Text_Color_2 );
-
- IF ( ( Drive_Ch = CHR( CR ) ) OR ( Drive_Ch = CHR( ESC ) ) ) THEN
- BEGIN
- WRITELN;
- WRITELN('*** Logged drive remains unchanged.')
- END
- ELSE
- BEGIN
- (* Figure no. of drives in system *)
-
- TextColor( Menu_Text_Color );
-
- Drive_Ch := UpCase( Drive_Ch );
-
- WRITE( Drive_Ch );
-
- Drive_Count := Dir_Count_Drives;
-
- (* Drive no. for entered letter *)
-
- Drive_No := ORD( Drive_Ch ) - ORD( 'A' );
-
- (* Check if drive legitimate *)
-
- IF ( ( Drive_No < 0 ) OR ( Drive_No > Drive_Count ) ) THEN
- WRITELN('*** Invalid drive, logged drive unchanged.')
- ELSE
- BEGIN
- (* Change default drive *)
-
- Dir_Set_Default_Drive( Drive_Ch );
-
- TextColor( Menu_Text_Color_2 );
-
- WRITELN;
- WRITE('*** Logged drive changed to ');
-
- TextColor( Menu_Text_Color );
- WRITE( Drive_Ch );
-
- END;
-
- END;
-
- DELAY( Two_Second_Delay );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Log_Drive_Change *);
-
- (*----------------------------------------------------------------------*)
- (* Change_Subdirectory --- Change current disk subdirectory *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Change_Subdirectory;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Change_Subdirectory *)
- (* *)
- (* Purpose: Change current subdirectory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Change_Subdirectory; *)
- (* *)
- (* Calls: Dir_Get_Default_Drive *)
- (* Dir_Set_Current_Path *)
- (* Dir_Get_Current_Path *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Path_Name : AnyStr;
- Iok : INTEGER;
- Drive_Ch : CHAR;
- New_Drive : CHAR;
- Drive_No : INTEGER;
- Drive_Count : INTEGER;
-
- BEGIN (* Change_Subdirectory *)
- (* Draw directory change menu *)
-
- Save_Partial_Screen( Saved_Screen, 5, 10, 75, 15 );
-
- Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Change Current Directory' );
-
- GoToXY( 1 , 1 );
-
- Drive_Ch := Dir_Get_Default_Drive;
-
- Iok := Dir_Get_Current_Path( Drive_Ch , Path_Name );
-
- IF ( Path_Name = '' ) THEN
- Path_Name := Drive_Ch + ':'
- ELSE
- Path_Name := Drive_Ch + ':\' + Path_Name;
-
- TextColor( Menu_Text_Color_2 );
- WRITELN('Enter name of new directory path: ');
- WRITE ('>');
-
- TextColor( Menu_Text_Color );
- Read_Edited_String( Path_Name );
-
- WRITELN;
-
- TextColor( Menu_Text_Color_2 );
-
- IF ( ( LENGTH( Path_Name ) = 0 ) OR ( Path_Name = CHR( ESC ) ) ) THEN
- WRITELN('*** Current directory remains unchanged.')
- ELSE
- BEGIN
-
- IF ( POS( ':' , Path_Name ) <> 0 ) THEN
- IF ( UpCase( Path_Name[1] ) <> Drive_Ch ) THEN
- BEGIN
- New_Drive := UpCase( Path_Name[1] );
- Drive_Count := Dir_Count_Drives;
- Drive_No := ORD( New_Drive ) - ORD( 'A' );
- IF ( Drive_No >= 0 ) AND ( Drive_No <= Drive_Count ) THEN
- Dir_Set_Default_Drive( New_Drive );
- END;
-
- IF Dir_Set_Current_Path( Path_Name ) = 0 THEN
- BEGIN
- Drive_Ch := Dir_Get_Default_Drive;
- Iok := Dir_Get_Current_Path( Drive_Ch , Path_Name );
- IF Path_Name <> '' THEN
- WRITELN('*** Current directory changed to ',
- Drive_Ch + ':\' + Path_Name )
- ELSE
- WRITELN('*** Current directory changed to ',
- Drive_Ch + ':' );
- END
- ELSE
- WRITELN('*** Error found, directory not changed');
- END;
-
- DELAY( Two_Second_Delay );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Change_Subdirectory *);
-
- (*----------------------------------------------------------------------*)
- (* Delete_A_File --- Delete a file *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Delete_A_File;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Delete_A_File *)
- (* *)
- (* Purpose: Delete file in current subdirectory *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Delete_A_File; *)
- (* *)
- (* Calls: Dir_Delete_File *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- File_Name : AnyStr;
-
- BEGIN (* Delete_A_File *)
- (* Draw delete file menu *)
-
- Save_Partial_Screen( Saved_Screen, 5, 10, 75, 15 );
-
- Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Delete A File -- Be Careful!' );
-
- TextColor( Menu_Text_Color_2 );
-
- GoToXY( 1 , 1 );
-
- WRITELN('Enter name of file to delete: ');
- WRITE('>');
-
- File_Name := '';
-
- TextColor( Menu_Text_Color );
-
- Read_Edited_String( File_Name );
- WRITELN;
-
- TextColor( Menu_Text_Color_2 );
-
- IF ( ( LENGTH( File_Name ) = 0 ) OR ( File_Name = CHR( ESC ) ) ) THEN
- WRITELN('*** No file to delete.')
- ELSE
- IF ( Dir_Delete_File( File_Name ) = 0 ) THEN
- WRITELN('*** File deleted.')
- ELSE
- WRITELN('*** File not found to delete or read-only');
-
- DELAY( Two_Second_Delay );
-
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Delete_A_File *);
-
- (*----------------------------------------------------------------------*)
- (* Find_Free_Space_On_Drive --- Find free space on a drive *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Find_Free_Space_On_Drive;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Find_Free_Space_On_Drive *)
- (* *)
- (* Purpose: Finds free space on a drive *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Find_Free_Space_On_Drive; *)
- (* *)
- (* Calls: Dir_Get_Free_Space *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- Drive_Ch: CHAR;
- Fspace: REAL;
-
- BEGIN (* Find_Free_Space_On_Drive *)
-
- Save_Partial_Screen( Saved_Screen, 10, 10, 61, 15 );
-
- Draw_Menu_Frame( 10, 10, 61, 15, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Free space on drive' );
-
- REPEAT
- GoToXY( 1 , 1 );
- ClrEol;
- Drive_CH := ' ';
- TextColor( Menu_Text_Color_2 );
- WRITE('Which drive? ');
- Read_Kbd( Drive_Ch );
- IF ( ( Drive_Ch = CHR( CR ) ) OR ( Drive_Ch = CHR( ESC ) ) ) THEN
- Drive_Ch := ' ';
- TextColor( Menu_Text_Color );
- WRITE( Drive_Ch );
- Drive_Ch := UpCase( Drive_Ch );
- UNTIL( Drive_Ch IN [' ','A'..'Z'] );
-
- TextColor( Menu_Text_Color_2 );
-
- IF Drive_Ch <> ' ' THEN
- BEGIN
- WRITELN;
- FSpace := Dir_Get_Free_Space( Drive_Ch );
- IF Fspace > 0.0 THEN
- WRITELN('Free space on drive ',Drive_Ch,' is ',Fspace:8:0,' bytes')
- ELSE
- WRITELN('Can''t find free space for drive ',Drive_Ch);
-
- WRITELN(' ');
- WRITE ('Hit ESC to continue');
-
- Read_Kbd( Drive_Ch );
-
- IF ( Drive_Ch = CHR( ESC ) ) AND KeyPressed THEN
- READ( Kbd, Drive_Ch );
-
- END;
-
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Find_Free_Space_On_Drive *);
-
- (*----------------------------------------------------------------------*)
- (* Copy_A_File --- Copy a file *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Copy_A_File;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Copy_A_File *)
- (* *)
- (* Purpose: Copies a file *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Copy_A_File; *)
- (* *)
- (* Calls: *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* Open_File_Handle *)
- (* Create_File_Handle *)
- (* Close_File_Handle *)
- (* Read_File_Handle *)
- (* Write_File_Handle *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- CONST
- BufSize = 4096 (* Buffer size *);
-
- VAR
- F_Handle : INTEGER (* File to be copied *);
- F_Size : REAL (* Size of file *);
- F_Open : BOOLEAN (* If F opened OK *);
- G_Handle : INTEGER (* File copied to *);
- G_Open : BOOLEAN (* If G opened OK *);
- G_Size : REAL (* Size of G *);
- F_Name : AnyStr (* Input file name *);
- G_Name : AnyStr (* Output file name *);
- Abort_Copy : BOOLEAN (* TRUE to stop copy *);
-
- BytesRead : INTEGER (* # of bytes read *);
- BytesDone : REAL (* Total bytes read *);
-
- (* Buffer area *)
- Buffer : PACKED ARRAY[ 1 .. BufSize ] OF CHAR;
-
- Err : INTEGER (* I/O error flag *);
- QErr : BOOLEAN (* If error occurs *);
-
- LABEL
- Abort_It;
-
- BEGIN (* Copy_A_File *)
- (* Announce file copy *)
-
- Save_Partial_Screen( Saved_Screen, 5, 10, 75, 17 );
-
- Draw_Menu_Frame( 5, 10, 75, 17, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Copy a file' );
-
- Abort_Copy := FALSE;
- Qerr := FALSE;
- (* Get name of file to copy *)
- REPEAT
-
- TextColor( Menu_Text_Color_2 );
- GoToXY( 1 , 1 );
- WRITE(' Enter file to be copied: ');
- ClrEol;
- F_Name := '';
-
- TextColor( Menu_Text_Color );
- Read_Edited_String( F_Name );
-
- IF ( ( LENGTH( F_Name ) = 0 ) OR ( F_Name = CHR( ESC ) ) ) THEN
- Abort_Copy := TRUE
- ELSE
- F_Size := Get_File_Size( F_Name, F_Open )
-
- UNTIL ( F_Open OR Abort_Copy );
-
- (* Stop if no input file *)
-
- IF Abort_Copy THEN GOTO Abort_It;
-
- (* Get name of file to copy to *)
- REPEAT
-
- TextColor( Menu_Text_Color_2 );
- GoToXY( 1 , 2 );
- WRITE(' Enter file to receive copy: ');
- ClrEol;
- G_Name := '';
- TextColor( Menu_Text_Color );
- Read_Edited_String( G_Name );
-
- IF ( ( LENGTH( G_Name ) = 0 ) OR ( G_Name = CHR( ESC ) ) ) THEN
- Abort_Copy := TRUE
- ELSE
- G_Size := Get_File_Size( G_Name, G_Open );
-
- IF G_Open THEN
- BEGIN
- GoToXY( 1 , 3 );
- G_Open := NOT YesNo(' File already exists, overwrite (Y/N)? ');
- END;
-
- UNTIL ( ( NOT G_Open ) OR Abort_Copy );
-
- (* Open input file *)
-
- Err := Open_File_Handle( F_Name, Access_Read_Mode, F_Handle );
-
- (* Open output file *)
-
- Err := Create_File_Handle( G_Name , Attribute_None , G_Handle );
-
- (* Report file size *)
- TextColor( Menu_Text_Color_2 );
-
- GoToXY( 1 , 4 );
- WRITE('Size of file ',F_Name,' in bytes is ',F_Size:8:0 );
-
- GoToXY( 1 , 5 );
- WRITE('Bytes copied: ');
-
- BytesDone := 0.0;
- (* Perform the copy *)
- REPEAT
-
- BytesRead := BufSize;
-
- Err := Read_File_Handle( F_Handle, Buffer, BytesRead );
-
- IF ( Err <> 0 ) THEN
- BEGIN
- GoToXY( 1 , 6 );
- WRITE('Error reading input file, copy stops.');
- Qerr := TRUE;
- END;
-
- IF ( ( BytesRead > 0 ) AND ( NOT Qerr ) ) THEN
- BEGIN
- Err := Write_File_Handle( G_Handle, Buffer, BytesRead );
- IF ( Err <> 0 ) THEN
- BEGIN
- GoToXY( 1 , 6 );
- WRITE('Error writing output file, copy stops.');
- Qerr := TRUE;
- END;
- END;
-
- BytesDone := BytesDone + BytesRead;
-
- GoToXY( 15 , 5 );
- WRITE( BytesDone:8:0 );
-
- UNTIL ( ( BytesRead < BufSize ) OR Qerr );
-
- (* Close files *)
-
- Err := Close_File_Handle( F_Handle );
- Err := Close_File_Handle( G_Handle );
-
- GoToXY( 1 , 6 );
-
- IF ( NOT Qerr ) THEN
- WRITE('Copy complete.');
-
- DELAY( Two_Second_Delay );
-
- Abort_It:
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Copy_A_File *);
-
- (*----------------------------------------------------------------------*)
- (* Print_A_File --- Initiate printing of a file *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Print_A_File;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Print_A_File *)
- (* *)
- (* Purpose: Initiates printing of a file *)
- (* *)
- (* Calling Sequence: *)
- (* *)
- (* Print_A_File; *)
- (* *)
- (* Calls: *)
- (* Save_Screen *)
- (* Restore_Screen *)
- (* Draw_Menu_Frame *)
- (* Reset_Global_Colors *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- F_Name : AnyStr;
- F_Open : BOOLEAN;
- Abort_Print : BOOLEAN;
- F_Size : REAL;
- Err : INTEGER;
-
- BEGIN (* Print_A_File *)
- (* Announce file print *)
-
- Save_Partial_Screen( Saved_Screen, 5, 10, 75, 15 );
-
- Draw_Menu_Frame( 5, 10, 75, 15, Menu_Frame_Color, Menu_Title_Color,
- Menu_Text_Color, 'Print a file' );
-
- (* Print a file not allowed *)
- (* if logging session to printer *)
-
- TextColor( Menu_Text_Color_2 );
-
- IF Printer_On THEN
- BEGIN
- WRITELN('Can''t print a file while session logging active.');
- DELAY( Two_Second_Delay );
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
- EXIT;
- END;
- (* Currently spooling -- see if *)
- (* we are to stop. *)
- IF Print_Spooling THEN
- BEGIN
- F_Open := YesNo('File already being printed, stop it (Y/N)? ');
- IF F_Open THEN
- BEGIN
- Print_Spooling := FALSE;
- Err := Close_File_Handle( Spool_File_Handle );
- DISPOSE( Spool_Buffer );
- END
- ELSE
- BEGIN
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
- EXIT;
- END;
- END;
-
- Abort_Print := FALSE;
- F_Open := FALSE;
- (* Get name of file to copy *)
- REPEAT
-
- GoToXY( 1 , 1 );
- WRITE(' Enter file to be printed: ');
- ClrEol;
- F_Name := '';
- TextColor( Menu_Text_Color );
- Read_Edited_String( F_Name );
- WRITELN;
- TextColor( Menu_Text_Color_2 );
-
- IF ( ( LENGTH( F_Name ) > 0 ) AND ( F_Name <> CHR( ESC ) ) ) THEN
- BEGIN
- F_Size := Get_File_Size( F_Name, F_Open );
- IF ( NOT F_Open ) THEN
- BEGIN
- WRITE('Can''t open that file.');
- ClrEol;
- DELAY( Two_Second_Delay );
- GoToXY( 1 , WhereY );
- ClrEol;
- END;
- END
- ELSE
- Abort_Print := TRUE;
-
- UNTIL ( F_Open OR Abort_Print );
-
- (* Stop if no file to print *)
- IF ( NOT Abort_Print ) THEN
- BEGIN
- (* Open file to print and read in *)
- (* first buffer full of data *)
-
- Err := Open_File_Handle( F_Name, Access_Read_Mode,
- Spool_File_Handle );
-
- NEW( Spool_Buffer );
-
- Spool_Buffer_Count := Max_Spool_Buffer_Count;
-
- Err := Read_File_Handle( Spool_File_Handle, Spool_Buffer^,
- Spool_Buffer_Count );
-
- Spool_Buffer_Pos := 0;
-
- Print_Spooling := TRUE;
-
- WRITELN;
- WRITELN('File ',F_Name,' starting to print.');
- DELAY( Two_Second_Delay );
-
- END;
- (* Restore previous screen *)
- Restore_Screen( Saved_Screen );
- Reset_Global_Colors;
-
- END (* Print_A_File *);
-